<?php

/**
 * historialpaquete actions.
 *
 * @package    courier
 * @subpackage historialpaquete
 * @author     Your name here
 */
class historialpaqueteActions extends sfActions
{
  public function executeIndex(sfWebRequest $request)
  {
    $this->Historialpaquetes = HistorialpaquetePeer::doSelect(new Criteria());
  }

  public function executeShow(sfWebRequest $request)
  {
    $this->Historialpaquete = HistorialpaquetePeer::retrieveByPk($request->getParameter('hist_id'));
    $this->forward404Unless($this->Historialpaquete);
  }

  public function executeNew(sfWebRequest $request)
  {
    $this->form = new HistorialpaqueteForm();
  }

  public function executeCreate(sfWebRequest $request)
  {
    $this->forward404Unless($request->isMethod(sfRequest::POST));

    $this->form = new HistorialpaqueteForm();

    $this->processForm($request, $this->form);

    $this->setTemplate('new');
  }

  public function executeEdit(sfWebRequest $request)
  {
    $this->forward404Unless($Historialpaquete = HistorialpaquetePeer::retrieveByPk($request->getParameter('hist_id')), sprintf('Object Historialpaquete does not exist (%s).', $request->getParameter('hist_id')));
    $this->form = new HistorialpaqueteForm($Historialpaquete);
  }

  public function executeUpdate(sfWebRequest $request)
  {
    $this->forward404Unless($request->isMethod(sfRequest::POST) || $request->isMethod(sfRequest::PUT));
    $this->forward404Unless($Historialpaquete = HistorialpaquetePeer::retrieveByPk($request->getParameter('hist_id')), sprintf('Object Historialpaquete does not exist (%s).', $request->getParameter('hist_id')));
    $this->form = new HistorialpaqueteForm($Historialpaquete);

    $this->processForm($request, $this->form);

    $this->setTemplate('edit');
  }

  public function executeDelete(sfWebRequest $request)
  {
    $request->checkCSRFProtection();

    $this->forward404Unless($Historialpaquete = HistorialpaquetePeer::retrieveByPk($request->getParameter('hist_id')), sprintf('Object Historialpaquete does not exist (%s).', $request->getParameter('hist_id')));
    $Historialpaquete->delete();

    $this->redirect('historialpaquete/index');
  }

  protected function processForm(sfWebRequest $request, sfForm $form)
  {
    $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
    if ($form->isValid())
    {
      $Historialpaquete = $form->save();

      $this->redirect('historialpaquete/edit?hist_id='.$Historialpaquete->getHistId());
    }
  }
}
